<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>管理分区</title>
    <!-- 导入jquery核心类库 -->
    <script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
    <!-- 导入easyui类库 -->
    <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="../../js/easyui/ext/portal.css">
    <link rel="stylesheet" type="text/css" href="../../css/default.css">
    <script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../js/easyui/ext/jquery.portal.js"></script>
    <script type="text/javascript" src="../../js/easyui/ext/jquery.cookie.js"></script>
    <script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>

    <script type="text/javascript">
        function doAdd() {
            $('#addWindow').window("open");
        }

        function doEdit() {
         
            
        }

        function doDelete() {
       
        }

        function doSearch() {
            $('#searchWindow').window("open");
        }

        //工具栏
        var toolbar = [{
            id: 'button-search',
            text: '查询',
            iconCls: 'icon-search',
            handler: doSearch
        }, {
            id: 'button-add',
            text: '增加',
            iconCls: 'icon-add',
            handler: doAdd
        }, {
            id: 'button-edit',
            text: '修改',
            iconCls: 'icon-edit',
            handler: doEdit
        }, {
            id: 'button-delete',
            text: '删除',
            iconCls: 'icon-cancel',
            handler: doDelete
        }];
        // 定义列
        var columns = [[{
            field: 'id',
            checkbox: true,
        }, {
            field: 'showid',
            title: '编号',
            width: 120,
            align: 'center',
            formatter: function (data, row, index) {
                return row.id;
            }
        }, {
            field: 'area.province',
            title: '省',
            width: 120,
            align: 'center',
            formatter: function (data, row, index) {
                if (row.area != null) {
                    return row.area.province;
                }
                return "";
            }
        }, {
            field: 'area.city',
            title: '市',
            width: 120,
            align: 'center',
            formatter: function (data, row, index) {
                if (row.area != null) {
                    return row.area.city;
                }
                return "";
            }
        }, {
            field: 'area.district',
            title: '区',
            width: 120,
            align: 'center',
            formatter: function (data, row, index) {
                if (row.area != null) {
                    return row.area.district;
                }
                return "";
            }
        }, {
            field: 'keyWords',
            title: '关键字',
            width: 120,
            align: 'center'
        }, {
            field: 'startNum',
            title: '起始号',
            width: 100,
            align: 'center'
        }, {
            field: 'endNum',
            title: '终止号',
            width: 100,
            align: 'center'
        }, {
            field: 'single',
            title: '单双号',
            width: 100,
            align: 'center'
        }, {
            field: 'assistKeyWords',
            title: '辅助关键字',
            width: 100,
            align: 'center'
        }]];

        $(function () {
            // 先将body隐藏，再显示，不会出现页面刷新效果
            $("body").css({visibility: "visible"});

            // 分区管理数据表格
            $('#grid').datagrid({
                iconCls: 'icon-forward',
                fit: true,
                border: true,
                rownumbers: true,
                striped: true,
                pageList: [30, 50, 100],
                pagination: true,
                toolbar: toolbar,
                url: "../../subarea_pageQuery.action",
                idField: 'id',
                columns: columns
            });

            // 添加、修改分区
            $('#addWindow').window({
                title: '添加修改分区',
                width: 600,
                modal: true,
                shadow: true,
                closed: true,
                height: 400,
                resizable: false
            });

            // 查询分区
            $('#searchWindow').window({
                title: '查询分区',
                width: 400,
                modal: true,
                shadow: true,
                closed: true,
                height: 400,
                resizable: false
            });
            //查询
            $("#btn").click(function () {
               
            });

            // 保存新增区域
            $('#save').click(function () {
                // 判断form元素 是否满足 校验规则
                if ($("#subareaForm").form('validate')) {
                    $("#subareaForm").submit();
                } else {
                    $.messager.alert("警告", "表单中存在非法输入项！", "warning");
                }
            });

            // 将form请求数据转换为json对象
            $.fn.serializeJson = function () {
                var serializeObj = {};
                var array = this.serializeArray();
                var str = this.serialize();
                $(array).each(function () {
                    if (serializeObj[this.name]) {
                        if ($.isArray(serializeObj[this.name])) {
                            serializeObj[this.name].push(this.value);
                        } else {
                            serializeObj[this.name] = [serializeObj[this.name], this.value];
                        }
                    } else {
                        serializeObj[this.name] = this.value;
                    }
                });
                return serializeObj;
            };


        });


    </script>
</head>

<body class="easyui-layout" style="visibility:hidden;">
<div region="center" border="false">
    <table id="grid"></table>
</div>
<!-- 添加 修改分区 -->
<div class="easyui-window" title="分区添加修改" id="addWindow" collapsible="false" minimizable="false" maximizable="false"
     style="top:20px;left:200px">
    <div style="height:31px;overflow:hidden;" split="false" border="false">
        <div class="datagrid-toolbar">
            <a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">保存</a>
        </div>
    </div>

    <div style="overflow:auto;padding:5px;" border="false">
        <form id="subareaForm" action="../../subarea_save.action" method="post">
            <table class="table-edit" width="80%" align="center">
                <tr class="title">
                    <td colspan="2">分区信息</td>
                </tr>
                <tr>
                    <td>分区编码</td>
                    <td>
                        <input type="text" name="id" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>选择区域</td>
                    <td>
                        <input id="areaId" name="area.id" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>区域名称</td>
                    <td id="areaName">
                    </td>
                </tr>
                <tr>
                    <td>关键字</td>
                    <td>
                        <input type="text" name="keyWords" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>辅助关键字</td>
                    <td>
                        <input type="text" name="assistKeyWords" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>起始号</td>
                    <td>
                        <input type="text" name="startNum" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>终止号</td>
                    <td>
                        <input type="text" name="endNum" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>单双号</td>
                    <td>
                        <select class="easyui-combobox" name="single" style="width:150px;">
                            <option value="0">单双号</option>
                            <option value="1">单号</option>
                            <option value="2">双号</option>
                        </select>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<!-- 查询分区 -->
<div class="easyui-window" title="查询分区窗口" id="searchWindow" collapsible="false" minimizable="false" maximizable="false"
     style="top:20px;left:200px">
    <div style="overflow:auto;padding:5px;" border="false">
        <form id="searchForm">
            <table class="table-edit" width="80%" align="center">
                <tr class="title">
                    <td colspan="2">查询条件</td>
                </tr>
                <tr>
                    <td>省</td>
                    <td>
                        <input type="text" name="area.province" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>市</td>
                    <td>
                        <input type="text" name="area.city" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>区（县）</td>
                    <td>
                        <input type="text" name="area.district" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td>关键字</td>
                    <td>
                        <input type="text" name="keyWords" class="easyui-validatebox" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2"><a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查询</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
</body>

</html>